<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/20
  Time: 19:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/allCss.css">
</head>
<body>
<div id="login">
    <br/>
    <h2>登录</h2>
    <%
        //账号
        String username = "";
        //密码
        String pwd = "";
        //复选框状态
        String ck = "";
        //获取cookie信息
        Cookie[] cookies = request.getCookies();
        //遍历cookies
        for (Cookie cookie : cookies) {
            //获取用户名
            if ("username".equals(cookie.getName())) { //判断cookie的name属性是不是为username
                username = cookie.getValue(); //将cookie的value属性赋值给username
                ck = "checked";             //将复选框的选中状态改变为选中
            }
            //获取密码
            if ("pwd".equals(cookie.getName())) {  //判断cookie的name属性是不是为pwd
                pwd = cookie.getValue();   //将cookie的value属性赋值给pwd
            }
        }
    %>
    <form action="${pageContext.request.contextPath}/UserServlet/login" method="post">
        账号:<input type="text" name="username" value="<%=username%>"class="text"><br/><br/>
        密码:<input type="password" name="pwd" value="<%=pwd%>"class="text"><br/>
        记住密码:<input type="checkbox" name="ck" value="1" <%=ck%>><br/>
        <button type="submit">登录</button><br/><br/>
    </form>
</div>
</body>
</html>
